
// F1. Distance from the Primary School, Enrollment, and Luo Vocabulary
// F1. Distance from the Primary School, Enrollment, and Luo Vocabulary
// F1. Distance from the Primary School, Enrollment, and Luo Vocabulary


// PRELIMINARIES

clear
set more off
set scheme s1mono

// LOAD DATA
	
use "JakielaOzierFernaldKnauer-preschool-data.dta", replace

cd "tmp"

drop if roundage==4 | roundage==5

gen age3 = roundage==3

sort age3 schdist randid
gen tempid = _n
sum tempid if age3==0
replace tempid = tempid - r(max) if age3==1

gen bin = cond(age3==1,ceil(tempid/53),ceil(tempid/51))
egen graphtag = tag(age3 bin)
bys age3 bin:  egen mean_enroll = mean(inschool)
bys age3 bin:  egen mean_dist = mean(schdist)
bys age3 bin:  egen mean_luovocab = mean(zluovocab)

tw ///
	(scatter mean_enroll mean_dist if age3==0, msymbol(o) mcolor(vermillion)) ///
	(lpolyci inschool mean_dist if age3==0, bw(0.1) lcolor(none) acolor(vermillion%18)) ///
	(scatter mean_enroll mean_dist if age3==0, msymbol(o) mcolor(vermillion)) ///
	(lpoly inschool mean_dist if age3==0, bw(0.1) lcolor(vermillion)), ///
	legend(off) title("Six Year Olds") ///
	ytitle("School Enrollment") ylabel(0.25(0.25)1.25) ///
	xtitle(" " "Distance to primary school (in km)") xlabel(0.1(0.1)0.7) saving(6yo, replace)
	
tw ///
	(scatter mean_enroll mean_dist if age3==1, msymbol(o) mcolor(sea)) ///
	(lpolyci inschool mean_dist if age3==1, bw(0.1) lcolor(none) acolor(sea%18)) ///
	(scatter mean_enroll mean_dist if age3==1, msymbol(o) mcolor(sea)) ///
	(lpoly inschool mean_dist if age3==1, bw(0.1) lcolor(sea)), ///
	legend(off) title("Three Year Olds") ///
	ytitle("School Enrollment") ylabel(0.25(0.25)1.25) ///
	xtitle(" " "Distance to primary school (in km)") xlabel(0.1(0.1)0.7) saving(3yo, replace)

graph combine 3yo.gph 6yo.gph, cols(2)

cd ..
graph export "out/F1A-lpoly-enroll.pdf", replace
cd "tmp"


tw ///
	(scatter mean_luovocab mean_dist if age3==0, msymbol(o) mcolor(vermillion)) ///
	(lpolyci zluovocab mean_dist if age3==0, bw(0.1) lcolor(none) acolor(vermillion%18)) ///
	(scatter mean_luovocab mean_dist if age3==0, msymbol(o) mcolor(vermillion)) ///
	(lpoly zluovocab mean_dist if age3==0, bw(0.1) lcolor(vermillion)), ///
	legend(off) title("Six Year Olds") ///
	ytitle("Luo Receptive Vocabulary Score") ylabel(-0.4(0.2)0.4) ///
	xtitle(" " "Distance to primary school (in km)") xlabel(0.1(0.1)0.7) saving(6yo, replace)
	
tw ///
	(scatter mean_luovocab mean_dist if age3==1, msymbol(o) mcolor(sea)) ///
	(lpolyci zluovocab mean_dist if age3==1, bw(0.1) lcolor(none) acolor(sea%18)) ///
	(scatter mean_luovocab mean_dist if age3==1, msymbol(o) mcolor(sea)) ///
	(lpoly zluovocab mean_dist if age3==1, bw(0.1) lcolor(sea)), ///
	legend(off) title("Three Year Olds") ///
	ytitle("Luo Receptive Vocabulary Score")  ylabel(-0.4(0.2)0.4) ///
	xtitle(" " "Distance to primary school (in km)") xlabel(0.1(0.1)0.7) saving(3yo, replace)

graph combine 3yo.gph 6yo.gph, cols(2)

cd ..
graph export "out/F1B-lpoly-luovocab.pdf", replace



